/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package py.una.pol.ii.is2.domain.sistema;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author markos
 */
@Entity
@Table(name = "pant_rol")
@NamedQueries({@NamedQuery(name = "PantRol.findAll", query = "SELECT p FROM PantRol p"), @NamedQuery(name = "PantRol.findByParoRol", query = "SELECT p FROM PantRol p WHERE p.pantRolPK.paroRol = :paroRol"), @NamedQuery(name = "PantRol.findByParoPantalla", query = "SELECT p FROM PantRol p WHERE p.pantRolPK.paroPantalla = :paroPantalla"), @NamedQuery(name = "PantRol.findByParoAcceso", query = "SELECT p FROM PantRol p WHERE p.paroAcceso = :paroAcceso")})
public class PantRol implements Serializable {
    private static final long serialVersionUID = 1L;
    public static final int ACCESO_READ_ONLY = 0;
    public static final int ACCESO_READ_WRITE = 1;
    @EmbeddedId
    protected PantRolPK pantRolPK;
    @Basic(optional = false)
    @Column(name = "paro_acceso")
    private int paroAcceso;
    @JoinColumn(name = "paro_pantalla", referencedColumnName = "pant_nombre", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Pantalla pantalla;
    @JoinColumn(name = "paro_rol", referencedColumnName = "rol_cod", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Rol rol;

    public PantRol() {
    }

    public PantRol(PantRolPK pantRolPK) {
        this.pantRolPK = pantRolPK;
    }

    public PantRol(PantRolPK pantRolPK, int paroAcceso) {
        this.pantRolPK = pantRolPK;
        this.paroAcceso = paroAcceso;
    }

    public PantRol(int paroRol, String paroPantalla) {
        this.pantRolPK = new PantRolPK(paroRol, paroPantalla);
    }

    public PantRolPK getPantRolPK() {
        return pantRolPK;
    }

    public void setPantRolPK(PantRolPK pantRolPK) {
        this.pantRolPK = pantRolPK;
    }

    public int getParoAcceso() {
        return paroAcceso;
    }

    public void setParoAcceso(int paroAcceso) {
        this.paroAcceso = paroAcceso;
    }

    public Pantalla getPantalla() {
        return pantalla;
    }

    public void setPantalla(Pantalla pantalla) {
        this.pantalla = pantalla;
    }

    public Rol getRol() {
        return rol;
    }

    public void setRol(Rol rol) {
        this.rol = rol;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pantRolPK != null ? pantRolPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PantRol)) {
            return false;
        }
        PantRol other = (PantRol) object;
        if ((this.pantRolPK == null && other.pantRolPK != null) || (this.pantRolPK != null && !this.pantRolPK.equals(other.pantRolPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.una.pol.ii.is2.dao.flota.PantRol[pantRolPK=" + pantRolPK + "]";
    }

}
